package com.tianji.learning.controller;

import com.tianji.common.domain.dto.PageDTO;
import com.tianji.learning.domain.po.InteractionQuestion;
import com.tianji.learning.domain.query.QuestionAdminPageQuery;
import com.tianji.learning.domain.vo.QuestionAdminVO;
import com.tianji.learning.domain.vo.QuestionReplyAdminVo;
import com.tianji.learning.service.IInteractionQuestionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@RequestMapping("/admin/questions")
@RequiredArgsConstructor
@Api(tags = "管理端-分页查询问题")
public class InteractionQuestionAdminController {

    private final IInteractionQuestionService questionService;

    /**
     * 分页查询问题(管理端)
     *
     * @param pageQuery
     * @return
     */
    @ApiOperation("分页查询问题(管理端)")
    @GetMapping("/page")
    public PageDTO<QuestionAdminVO> selectAdminPage(@Validated QuestionAdminPageQuery pageQuery) {
        log.info("调用>>>分页查询问题(管理端)");
        return questionService.selectAdminPage(pageQuery);
    }

    /**
     * 根据id查询问题详情(管理端)
     *
     * @param id
     * @return
     */
    @ApiOperation("根据id查询问题详情(管理端)")
    @GetMapping("/{id}")
    public QuestionReplyAdminVo selectDetailById(@PathVariable("id") Long id) {
        log.info("调用>>>根据id查询问题详情(管理端)");
        return questionService.selectDetailById(id);
    }
}
